/**
*@author       wuwg
*@createTime   2018/03/20
*@updateTime   2018/04/03
*@description
*@rule
 */
@import '../../../config/config.less';

@css-prefix-switch: ~"@{css-prefix}switch";

.@{css-prefix-switch} {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
  line-height: 22px;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
  transition: all @transition-time @ease-in-out;

  input[type="checkbox"] {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    width: 0;
    height: 0;
    visibility: hidden;
    opacity: 0;
  }
  //  内部,默认default status
  &-inner {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    padding: 0 7px;
    width: 100%;
    height: 100%;
    color: #fff;
    font-size: @font-size-small;
    border: 1px solid #ccc;
    background-color: #ccc;
    border-radius: 24px;
    &:focus {
      box-shadow: 0 0 0 2px fade(@primary-color, 20%);
      outline: 0;
    }

    &:focus:hover {
      box-shadow: none;
    }

    :first-child {
      float: left;
    }
    :last-child {
      float: right;
    }
    // 按钮
    &:after {
      content: '';
      position: absolute;
      left: 1px;
      top: 1px;
      z-index: 1;
      width: 20px;
      height: 20px;
      border-radius: 20px;
      background-color: #fff;
      cursor: pointer;
      transition: left @transition-time @ease-in-out, width @transition-time @ease-in-out;
    }
    // 激活状态
    &:active:after {
      width: 26px;
    }
  }
  // 选中
  input[type="checkbox"]:checked + &-inner{
    border-color: @primary-color;
    background-color: @primary-color;
    &:after {
      left: 25px;
    }
  }

  // 禁用
  input[type="checkbox"]:disabled + &-inner{
    cursor: @cursor-disabled;
    color: #ccc;
    background: #f3f3f3;
    border-color: #f3f3f3;
    &:focus {
      box-shadow: none;
    }
    &:after {
      background: #ccc;
      cursor: not-allowed;
    }
  }
}
